package com.sgb.kjwl.view.widget.lease.common;

import android.content.Context;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.sgb.kjwl.BR;
import com.sgb.kjwl.R;
import com.swgk.core.base.model.entity.VideoBean;

public class HomeLeaseVideoAdapter extends CommonBaseAdapter<VideoBean, CommonItemViewHolder> {
    public HomeLeaseVideoAdapter(Context context) {
        super(context);
    }

    @Override
    protected CommonItemViewHolder onCreateViewHolderImpl(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(mContext).inflate(R.layout.item_lease_home_video, parent, false);
        return new CommonItemViewHolder(view);
    }

    @Override
    protected void onBindViewHolderImpl(CommonItemViewHolder holder, int position) {
        VideoBean entity = getItem(position);
        holder.getBinding().setVariable(BR.viewModel, entity);
        TextView textView = holder.itemView.findViewById(R.id.tv_labelName);
        if (!TextUtils.isEmpty(entity.getTitle())){
            textView.setText(entity.getTitle());
        }else {
            textView.setText("");
        }
        String names = textView.getText().toString();
        if (!TextUtils.isEmpty(entity.getLabelName())){
            if (entity.getLabelName().length()>=7){
                textView.setText("# "+entity.getLabelName().substring(0,6)+"...\n"+names);
            }else {
                textView.setText("# "+entity.getLabelName()+" "+names);
            }
        }
    }

    @Override
    protected boolean isVertical() {
        return false;
    }
}
